package com.haipumi.listeners;

import java.util.List;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import com.haipumi.beans.haipumi_product;
import com.haipumi.biz.GoodsBiz;
import com.haipumi.biz.impl.GoodsBizImpl;
import com.haipumi.utils.CommonData;

public class GoodsListener implements ServletContextListener{

	@Override
	public void contextDestroyed(ServletContextEvent arg0) {
	}

	@Override
	public void contextInitialized(ServletContextEvent arg0) {
		//访问数据库,得到所有的商品存到application中
		GoodsBiz foodBiz=new GoodsBizImpl();
		List<haipumi_product> list=foodBiz.findAllGoods();
		//如何取出application
		
		ServletContext application=arg0.getServletContext();
		application.setAttribute(CommonData.APPLICATIONPRODUCTKEY, list);
	}

}
